package jrain.fw.script.expression;

import java.util.Map;

import jrain.fw.script.resolver.VariableResolver;
import jrain.fw.script.tools.ELException;
import jrain.fw.script.tools.Logger;

public class PropertySuffix extends ArraySuffix {
	// -------------------------------------
	// Properties
	// -------------------------------------
	// property name

	String mName;

	public String getName() {
		return mName;
	}

	public void setName(String pName) {
		mName = pName;
	}

	// -------------------------------------

	/**
	 * Constructor
	 */
	public PropertySuffix(String pName) {
		super(null);
		mName = pName;
	}

	// -------------------------------------

	/**
	 * Gets the value of the index
	 */
	Object evaluateIndex(Object pContext, VariableResolver pResolver, Map<Object, Object> functions, String defaultPrefix, Logger pLogger) throws ELException {
		return mName;
	}

	// -------------------------------------

	/**
	 * Returns the operator symbol
	 */
	String getOperatorSymbol() {
		return ".";
	}

	// -------------------------------------
	// ValueSuffix methods
	// -------------------------------------

	/**
	 * Returns the expression in the expression language syntax
	 */
	public String getExpressionString() {
		return "." + StringLiteral.toIdentifierToken(mName);
	}

	// -------------------------------------
}
